/**
 * 0. Project	: com.dnbns.bodywater.adapter 프로젝트
 *
 * 1. FileName	: RecordAdapter.java
 * 2. Package	: com.dnbns.bodywater.adapter
 * 3. 작성자		: 윤화현
 * 4. 작성일		: 2013. 12. 5. 오후 2:34:26
 * 5. Comment	: 
 */

package com.dnbns.bodywater.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.dnbns.bodywater.R;
import com.dnbns.bodywater.bean.RecordBean;
import com.dnbns.lib.CodeUtil;

public class RecordAdapter extends ArrayAdapter<RecordBean> {
	private static final int VIEW_RESOURCE_ID = R.layout.row_record;
	private Context mContext;
	private LayoutInflater mInflater;
	
	public RecordAdapter(Context context, ArrayList<RecordBean> list){
		super(context, VIEW_RESOURCE_ID, list);
		mContext = context;
		mInflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
    
	@Override
	public View getView(final int position, View convertView, ViewGroup parent){
		View view = convertView;
		if(view == null){
			view = mInflater.inflate(VIEW_RESOURCE_ID, null); 
		}

		final RecordBean item = getItem(position);
    	if (item != null) {
    		TextView ml = (TextView)view.findViewById(R.id.ml);
    		ml.setText(item.getCup_vol()+"ml");
    		
    		TextView date = (TextView)view.findViewById(R.id.date);
    		date.setText(CodeUtil.addZero(item.getHour())+":"+CodeUtil.addZero(item.getMinute()));
    	}
		return view;
	}
}